home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_8 / issue_06 / risc_os / Wimp / Messages < prev    next >
Encoding:
Text File  |  1988-12-06  |  25.4 KB  |  686 lines

  1. > Spec.Messages
  2.  
  3. New Calls
  4. ---------
  5.  
  6.         Wimp_SendMessage
  7.         Wimp_Poll:  reason codes 17,18,19
  8.         Wimp_TransferBlock
  9.  
  10.  
  11. SWI Wimp_SendMessage
  12. --------------------
  13.  
  14.   Entry:  R0 = reason code to be returned to receiving task
  15.           R1 --> block containing message
  16.           R2 = task handle of task to receive message
  17.        or R2 = window handle (message is sent to owner of window/icon)
  18.           R3 = icon handle   (required if R2 = iconbar window handle (-2))
  19.        or R2 = 0             (message is broadcast to all tasks in turn)
  20.  
  21.   Exit:   R2 = task handle of receiver (unless R2=0 on entry)
  22.           the message is queued
  23.           the block is updated if R0 was 17 or 18 on entry
  24.  
  25. The messages are queued on a First-In-First-Out basis, and are delivered when
  26. Wimp_Poll is next called.  Note that a message will only be delivered if the
  27. receiving task is still active, and has not masked out the relevant reason
  28. code (R0 on entry to Wimp_Poll = mask).  Messages sent to a window/icon
  29. rather than a task are also tagged so that if the window or icon is deleted
  30. then the message is not delivered.
  31.  
  32. Note that pending messages take priority over any other kind of action which
  33. might return a reason code from Wimp_Poll.
  34.  
  35.  
  36. Wimp_Poll reason codes
  37. ----------------------
  38.  
  39.         Code    Meaning                         Block size (bytes)
  40.  
  41.         0       Null                            0
  42.         1       Redraw_Window                   4
  43.         2       Open_Window                     32
  44.         3       Close_Window                    4
  45.         4       Pointer_Leaving_Window          4
  46.         5       Pointer_Entering_Window         4
  47.         6       Mouse_Click                     24
  48.         7       User_DragBox                    16
  49.         8       Key_Pressed                     28
  50.         9       Menu_Selection                  variable
  51.         10      Scroll_Window                   40
  52.         11      Lose_Caret                      24
  53.         12      Gain_Caret                      24
  54.         13..16  Reserved
  55.         17      User_Message                    variable
  56.         18      User_Message_Recorded           variable
  57.         19      User_Message_Acknowledge        variable
  58.  
  59.  
  60. Wimp_SendMessage with R0 = 17,18,19 (User_Message)
  61. --------------------------------------------------
  62.  
  63. In addition to sending 'ordinary' reason codes to other tasks, such as
  64. Open_Window_Request or Mouse_Click, Wimp_SendMessage can be used to send
  65. message blocks, using the new reason codes 17,18 and 19.
  66.  
  67. The format of the block on entry to Wimp_SendMessage in these cases is as
  68. follows:
  69.  
  70. Entry:
  71.         +0      size of block ( 20<=size<=256, size MOD 4 = 0)
  72.         +4      not used
  73.         +8      not used
  74.         +12     your_ref (0 if not replying to a previous message)
  75.         +16     message action (unique)
  76.         +20..   message data (format depends on message action)
  77.  
  78. Exit:
  79.         +4      task handle of sender (ie. this task)
  80.         +8      my_ref (reference number of message (unique non-zero word))
  81.  
  82. The two fields on exit are filled in by Wimp_SendMessage, and will also be
  83. included in the block received at the other end.
  84.  
  85.  
  86. The three different reason codes (17,18,19) have the following meanings when
  87. given to Wimp_SendMessage:
  88.  
  89.  
  90. 17  User_Message
  91.  
  92. The message is sent by the Wimp to the relevant task.
  93.  
  94. If the message is not delivered (eg. if the task is dead, or it just ignores
  95. it), then nothing happens.
  96.  
  97.  
  98. 18  User_Message_Recorded
  99.  
  100. The message is sent by the Wimp to the relevant task.
  101.  
  102. If the message is not acknowledged by the receiving task, then the Wimp will
  103. return the message to the original sender, with the reason code changed to
  104. 19.  To acknowledge a message, the receiving task must send another message
  105. with its 'your_ref' field set to the 'my_ref' field of the original message,
  106. before it calls Wimp_Poll again.
  107.  
  108.  
  109. 19  User_Message_Acknowledge
  110.  
  111. The message identified by the your_ref field is acknowledged.
  112.  
  113. In order to acknowledge a message (ie. to prevent it from being returned to
  114. the sender), the receiving task can either send another message or send a
  115. User_Message_Acknowledge, which will acknowledge the message without actually
  116. sending one in reply.  In either case, the my_ref field of the original
  117. message should be copied into the your_ref field of the new message, in order
  118. to acknowledge it.
  119.  
  120. If the original message was a broadcast, acknowledging it will prevent it
  121. from being passed to any further tasks.
  122.  
  123. Note that sending a message type 19 with your_ref=0 and R2/R3 = window/icon
  124. handle is one way to discover the handle of the task owning a window/icon (on
  125. exit from Wimp_SendMessage R2=task handle) without actually sending a
  126. message.
  127.  
  128.  
  129. Wimp_Poll reason codes 17,18,19
  130. -------------------------------
  131.  
  132. Note that when receiving messages, a task should not distinguish between
  133. message types 17 and 18 in terms of their function - it is the 'message
  134. action' field which uniquely determines the purpose of a message.
  135.  
  136. Wimp_Poll reason code 19 means that a type 18 message you sent has been
  137. returned to you, since it was not acknowledged (see above).
  138.  
  139.  
  140. Message Actions
  141. ---------------
  142.  
  143. It is envisaged that, in addition to the 'system' message actions (see
  144. below), various families of applications may wish to send messages to each
  145. other.  To ensure that message actions do not clash, it has been decided that
  146. the message numbers will be allocated in parallel with SWI chunk numbers. 
  147. Thus, if you have already been allocated a SWI chunk, you can use message
  148. actions in that range for private purposes.  If you have not been allocated
  149. any SWI chunks, and you need one, you should apply to Acorn to get it!
  150.  
  151. The following message actions have been defined so far:
  152.  
  153.              0  Message_Quit
  154.              1  Message_DataSave
  155.              2  Message_DataSaveAck
  156.              3  Message_DataLoad
  157.              4  Message_DataLoadAck
  158.              5  Message_DataOpen
  159.              6  Message_RAMFetch
  160.              7  Message_RAMTransmit
  161.              8  Message_PreQuit
  162.              9  Message_PaletteChange
  163.  
  164.           &400  Message_FilerOpenDir
  165.           &401  Message_FilerCloseDir
  166.  
  167.         &40040  Message_Notify
  168.  
  169.         &400C0  Message_MenuWarning
  170.         &400C1  Message_ModeChange
  171.         &400C2  Message_TaskInitialise
  172.         &400C3  Message_TaskCloseDown
  173.         &400C4  Message_SlotSize
  174.         &400C5  Message_SetSlot
  175.         &400C6  Message_TaskNameRq
  176.         &400C7  Message_TaskNameIs
  177.  
  178.  
  179. 0  Quit (broadcast)
  180.  
  181.    R0 = 17/18
  182.    R1!0 = size of data
  183.    R1!12= 0                     ; your ref.
  184.    R1!16= 0                     ; action
  185.  
  186. On receipt of this message, a running Wimp task should tidy up and close
  187. down, by calling Wimp_CloseDown and OS_Exit.  At this stage, the task should
  188. not refuse to close down - if the task has any unsaved data, it should object
  189. when it receives the PreQuit message (8), which is always issued prior to the
  190. Quit message (see below).
  191.  
  192.  
  193. 1..7  Data transfer protocol
  194.  
  195. These messages are detailed in a separate section below.
  196.  
  197.  
  198. 8  PreQuit (broadcast)
  199.  
  200.    R0 = 17/18
  201.    R1!0 = size of data
  202.    R1!12= 0                     ; your ref.
  203.    R1!16= 8                     ; action
  204.  
  205. On receipt of this message, a running Wimp task should check to see if any
  206. data would be lost if it were to close down (ie. if any files have been
  207. modified but not saved).  If not, the message should be ignored, and the
  208. sender of the PreQuit message will follow it up with a Quit message, causing
  209. the task to close down.
  210.  
  211. If the task has unsaved data, it should acknowledge the PreQuit message (SWI
  212. Wimp_SendMessage with R0=19, R1->original block, R1!8 copied into R1!12), and
  213. bring up a suitable dialogue box so that the user can specify whether to save
  214. or discard the files.
  215.  
  216. If the user subsequently decides to discard the files, the application
  217. should restart the closedown sequence by sending a CTRL-SHIFT-f12 keypress
  218. event to the sender of the PreQuit message, as follows:
  219.  
  220.         SYS "Wimp_GetCaretPosition",,R1     :REM fill up first 5 words
  221.         R1!24 = &1FC                        :REM CTRL-SHIFT-f12
  222.         SYS "Wimp_SendMessage",17,R1,prequittask%
  223.  
  224. (prequittask% is the task handle of the sender of the PreQuit message, which
  225. can be read from the original message block).
  226.  
  227. The Task Manager module provides a global 'Exit' option, which it executes
  228. on receipt of a CTRL-SHIFT-f12 as follows:
  229.  
  230.         1. SWI Wimp_SendMessage, 17,prequitblk,0
  231.         2. prequitref = prequitblk!8          ; remember myref field
  232.  
  233.         3. On receipt of Wimp_Poll (19),
  234.                if message!8 = prequitref then:
  235.                  SWI Wimp_SendMessage, 18,quitblk,0
  236.                  quitref = quitblk!8          ; remember myref field
  237.  
  238.         3. On receipt of Wimp_Poll (17/18),
  239.                if message action = Quit then
  240.                  if message block!8 <> quitref then <quit>
  241.         4. On receipt of Wimp_Poll (19),
  242.                if message action = Quit then
  243.                  if message block!8 = quitref then <quit>
  244.  
  245. The Task Manager issues the PreQuit broadcast first - if this is not acknowledged
  246. by any task, it proceeds to issue the Quit broadcast.  This means that if any
  247. task objects to being closed down, it does so before any of the other tasks
  248. is closed down.  It also means that if any task contains unsaved data, the
  249. task will not be closed down, and the user must re-select the quit option
  250. after responding to the task's save/discard confirmation sequence.
  251.  
  252. After sending the Quit broadcast, the Task Manager does not quit itself until it
  253. receives its own message back to confirm that all other tasks have been
  254. closed down successfully.  However, if it receives the message from another
  255. task, it should close down immediately.
  256.  
  257. Note that the Task Manager responds to CTRL-SHIFT-f12 being pressed by using
  258. a 'grabkeys' window (bit 12 of window flags set) to respond to the user
  259. pressing the key.  Note that due to the above protocol, any form of
  260. closedown sequence (such as one that is required in order to boot a new
  261. operating system) must respond to the CTRL-SHIFT-f12 keypress message, even
  262. if it is never passed user keystrokes (indeed, it should not respond to the
  263. actual user keystrokes, since the Task Manager is supposed to deal with
  264. that).
  265.  
  266.  
  267. 9  Message_PaletteChange (broadcast)
  268.  
  269.    R0 = 17/18
  270.    R1!0 = size of data
  271.    R1!12= 0                     ; your ref.
  272.    R1!16= 9                     ; action
  273.  
  274. This message should not be acknowledged by any task.
  275.  
  276. The palette utility issues this broadcast whenever the user finishes dragging
  277. any of the RGB bars in the palette window, or loads a new palette file.
  278.  
  279. On receipt of the PaletteChange message, a task which needs to alter any
  280. internal tables or colour mappings when a palette change occurs should do so,
  281. and call Wimp_ForceRedraw if necessary to ensure that the relevant changes
  282. are reflected on the screen.
  283.  
  284. Note that since the palette utility will automatically invalidate the whole
  285. screen if any of the Wimp's colours change their logical mapping, most tasks
  286. do not need to take any notice of this message.  See Wimp.Colours for further
  287. details of the Wimp colour mappings.
  288.  
  289. This message is not issued when the mode changes, so Message_ModeChange
  290. (&400C1) should also be trapped by tasks needing to act on colour mappings.
  291.  
  292.  
  293. NetFiler messages
  294. -----------------
  295.  
  296. The netfiler uses messages in the NetFS module SWI range (&40040-&4007F).
  297.  
  298. &40040  Message_Notify (broadcast)
  299.  
  300.    R0 = 17/18
  301.    R1!0 = size of data
  302.    R1!12= 0
  303.    R1!16= &40040
  304.    R1?20= station number } of sending station
  305.    R1?21= network number }
  306.    R1?22..R1?26 = 5-byte real time when message was received
  307.    R1?27..      = message (0-terminated)
  308.  
  309. The NetFiler offers this broadcast around to make it easy for another
  310. application to pick up the message and display it in some nice way for the
  311. user.  If the message is not acknowledged, the NetFiler will simply call
  312. Wimp_ReportError with the message in the error box, and the string 'Message
  313. from station xxx.xxx' in the title bar.
  314.  
  315.  
  316. Wimp messages
  317. -------------
  318.  
  319. The Wimp-specific messages are allocated in the range &400C0-&400FF (in its
  320. SWI range).
  321.  
  322.  
  323. &400C0  Message_MenuWarning
  324.  
  325.    R0 = 17/18
  326.    R1!0 = size of data
  327.    R1!12= 0
  328.    R1!16= &400C0
  329.    R1!20= address of submenu data
  330.    R1!24= x-coordinate of top-left of menu
  331.    R1!28= y-coordinate of top-left of menu
  332.    R1!32= list of menu selection numbers, terminated by -1
  333.  
  334. This message will only be delivered by the Wimp if bit 3 of the menu flags of
  335. a menu item is set, and the submenu pointer is not null.  If this is true,
  336. and the user moves the mouse pointer over the right-arrow icon of the menu
  337. entry, then instead of directly opening the relevant submenu, the Wimp will
  338. generate this message.  After processing the information contained in the
  339. message block (and possibly amending the submenu data) the application should
  340. respond by calling Wimp_CreateSubMenu with the parameters in the message
  341. block at offsets 20,24 and 28 (ie. the menu data pointer and x,y
  342. coordinates).  Note that the submenu could be a dialogue window handle.
  343.  
  344. The list of menu selection numbers indicates the current state of the menu
  345. tree, and is the same as that returned by Wimp_Poll (Menu_Select).  This
  346. information, together with the application's record of which menu tree it
  347. last created, is sufficient to determine whereabouts in the menu tree the
  348. Wimp currently is.
  349.  
  350.  
  351. &400C1  Message_ModeChange (broadcast)
  352.  
  353.    R0 = 17/18
  354.    R1!0 = size of data (20)
  355.    R1!12= 0
  356.    R1!16= &400C1
  357.  
  358. On receiving this message, a task which needs to make adjustments on a mode
  359. change shuld do so.  Note that the mode number is not supplied in the message
  360. - tasks should NOT use the mode number to determine the vdu variables, but
  361. should instead call OS_ReadVduVariables.
  362.  
  363. After sending the Message_ModeChange, the Wimp sends an Open_Window_Request
  364. for each window that was open at the time the Wimp_SetMode occurred.  This
  365. is designed so that if the screen width is reduced (eg. if going from mode
  366. 16 to mode 12), the windows will be 'scrunched' into the visible portion of
  367. the screen.  The mode change also causes the entire screen area to be marked
  368. invalid, so all windows will be redrawn.
  369.  
  370. There is a problem, however: if a task wishes to modify a window after the
  371. mode change in a way which requires it to be deleted and re-created, the
  372. window handle will change.  Unfortunately problems will result if this is
  373. done on receipt of the Message_ModeChange, since the Wimp will subsequently
  374. return an Open_Window_Request for the OLD window handle, not the new one.
  375.  
  376. The solution is that if you need to change the window handle in this way,
  377. you should not do it until you receive the Open_Window_Request for the
  378. relevant window - in other words, on the Message_ModeChange you should mark
  379. the window 'dirty' (in some internal data structure), and on
  380. Open_Window_Request check the 'dirty' flag and do the deletion/recreation
  381. stuff if required.
  382.  
  383.  
  384. &400C2  Message_TaskInitialise (broadcast)
  385.  
  386.    R0 = 17/18
  387.    R1!0 = size of block (including header)
  388.    R1!4 = task handle of new task
  389.    R1!12= 0
  390.    R1!16= &400C2
  391.    R1!20= CAO pointer of task
  392.    R1!24= amount of application memory used by task
  393.    R1+28..= <task name, as pointed to by R2 on entry to Wimp_Initialise>
  394.  
  395. Issued by the Wimp when a task calls Wimp_Initialise.  This message is
  396. picked up by the Task Manager module, and enables it to maintain a list of
  397. running tasks.  Note that the Task Manager will only notice tasks which
  398. start up after it, so it should be the first desktop module in the module
  399. list.
  400.  
  401.  
  402. &400C3  Message_TaskCloseDown (broadcast)
  403.  
  404.    R0 = 17/18
  405.    R1!0 = size of block (20)
  406.    R1!4 = task handle of dying task
  407.    R1!12= 0
  408.    R1!16= &400C3
  409.  
  410. Issued by the Wimp when a task calls Wimp_CloseDown (if a task calls OS_Exit
  411. prematurely, the Wimp will call Wimp_CloseDown for it).  The Task Manager
  412. module is again the main client of this message.
  413.  
  414.  
  415. &400C4  Message_SlotSize (broadcast)
  416.  
  417.    R0 = 17/18
  418.    R1!0 = size of block (28)
  419.    R1!4 = task handle of task owning current slot
  420.    R1!12= 0
  421.    R1!16= &400C4
  422.    R1!20= new current slot size
  423.    R1!24= new next slot size
  424.  
  425. This message is broadcast by the Wimp whenever Wimp_SlotSize is used to
  426. alter the amount of memory owned by a task.  It is normally picked up by the
  427. Task Manager module to allow it to maintain its display of memory
  428. allocation.
  429.  
  430. This message should not be acknowledged, since that would stop any other
  431. utilities from picking it up.
  432.  
  433.  
  434. &400C5  Message_SetSlot
  435.  
  436.    R0 = 17/18
  437.    R1!0 = size of block (28)
  438.    R1!12= 0
  439.    R1!16= &400C5
  440.    R1!20= new current slot size
  441.    R1!24= task handle of task whose slot should be changed
  442.  
  443. This message is sent to a task by the Task Manager when the user drags the
  444. task's slot, if the task has initially told the Task Manager that it can
  445. deal with dynamic drags by acknowledging a message of this form when it
  446. started up.  On receipt of this message, the task should (if R1!20 >= 0)
  447. call Wimp_SlotSize to alter its slot size to the appropriate value.  See
  448. Wimp.Switcher for further details.
  449.  
  450.  
  451. &400C6  Message_TaskNameRq
  452.  
  453.    R0 = 17/18
  454.    R1!0 = size of block (24)
  455.    R1!12= 0
  456.    R1!16= &400C6
  457.    R1!20= task handle of task being asked about
  458.  
  459. If a task wishes to find out the name of a task given its handle, it should
  460. broadcast this message.  If the Task Manager is running, and it recognises
  461. the task handle, it will reply with the following message:
  462.  
  463.  
  464. &400C7  Message_TaskNameIs
  465.  
  466.    R0 = 17/18
  467.    R1!0 = size of block
  468.    R1!12= myref of previous message
  469.    R1!16= &400C7
  470.    R1!20= task handle of task being asked about
  471.    R1!24= task's slot size
  472.    R1+28..= <task name, as pointed to by R2 on entry to Wimp_Initialise>
  473.             (0-terminated)
  474.  
  475. This message pair is used by the !Help application so that it can provide
  476. extra help about the ROM modules (which have defined names).
  477.  
  478.  
  479. Data Transfer Protocol
  480. ----------------------
  481.  
  482. 1  Message_DataSave
  483.  
  484.    R0     17 (usually)
  485.    R1!0   size
  486.      !12  0
  487.      !16  1 ; DataSave
  488.      !20  destination window handle             ;
  489.      !24  destination window icon               ; copied from
  490.      !28  destination x coord (screen coords)   ; Wimp_GetPointerInfo
  491.      !32  destination y coord (screen coords)   ;
  492.      !36  estimated size of data, in bytes
  493.      !40  file type of data
  494.      !44  proposed leaf-name of file, 0-terminated
  495.  
  496.  
  497. 2  Message_DataSaveAck (save data to file)
  498.  
  499.    R0     17 (usually)
  500.    R1!0   size
  501.      !12  my-ref field of DataSave message
  502.      !16  2 ; save data to here
  503.      !20  destination window handle             ;
  504.      !24  destination window icon               ; preserved from
  505.      !28  destination x coord (screen coords)   ; Message_DataSave
  506.      !32  destination y coord (screen coords)   ;
  507.      !36  estimated size of data, in bytes      ; -1 if file is 'unsafe'
  508.      !40  file type of data
  509.      !44  full-name of file, 0-terminated
  510.  
  511. Where this message is used as part of the scrap transfer protocol (see
  512. below), the 'estimated size' field is set to -1 by the sender, to tell the
  513. receiver that his file will NOT be 'safe' after it has been saved to the
  514. destination.  Typically a file called <Wimp$Scrap> will be saved, and it is
  515. not considered a good idea to put '<Wimp$Scrap>' in the title bar of the
  516. document that has just been saved, or to mark it unmodified, since the scrap
  517. file will be deleted after the sender gets back a DataLoad (see below).
  518.  
  519.  
  520. 3  Message_DataLoad (drag file from Filer / I have saved data to a file)
  521.  
  522.    R0     18 (usually)
  523.    R1!0   size
  524.      !12  my-ref field of DataSaveAck message (or 0 if from Filer)
  525.      !16  3 ; load data from here
  526.      !20  destination window handle             ;
  527.      !24  destination icon handle               ; copied from
  528.      !28  destination x coord (screen coords)   ; Wimp_GetPointerInfo
  529.      !32  destination y coord (screen coords)   ;
  530.      !36  estimated size of data, in bytes
  531.      !40  file type
  532.      !44  full path-name of file, zero-terminated
  533.  
  534. The filer sends this message when a file has been dragged into a window
  535. belonging to another application.  The application is then free to copy
  536. or insert the file, if it so desires.
  537.  
  538. If the application can load files of the relevant type, and the file is
  539. loaded successfully, it should reply as follows:
  540.  
  541.  
  542. 4  Message_DataLoadAck
  543.  
  544.    R0     17 (usually)
  545.    R1!0   size
  546.      !12  my-ref field of DataLoad message
  547.      !16  4 ; DataLoadAck
  548.      !20  destination window handle             ;
  549.      !24  destination icon handle               ; copied from
  550.      !28  destination x coord (screen coords)   ; Wimp_GetPointerInfo
  551.      !32  destination y coord (screen coords)   ;
  552.      !36  estimated size of data, in bytes
  553.      !40  file type
  554.      !44  full path-name of file, zero-terminated
  555.  
  556.  
  557. 5  Message_DataOpen (broadcast for double-clicked file)
  558.  
  559.    R0     18 (usually)
  560.    R1!0   size
  561.      !12  0
  562.      !16  5                 ; destination info request
  563.      !20  window handle of directory viewer
  564.      !24  unused
  565.      !28  x-offset of icon being opened within viewer
  566.      !32  y                 ; allows for 'zoom' box if implemented
  567.      !36  estimated size of data, in bytes
  568.      !40  file type
  569.      !44  full path-name of file, 0-terminated.
  570.  
  571. DataLoadAck is returned by the application which loads the file.
  572.  
  573.  
  574. 6  Message_RAMFetch (transfer data to buffer in my workspace)
  575.  
  576.    R0     18 (error message if not acknowledged)
  577.    R1!0   size
  578.      !12  my-ref field of DataSave message
  579.      !16  6 ; RAM fetch.
  580.      !20  buffer address
  581.      !24  buffer size (bytes)
  582.  
  583.  
  584. 7  Message_RAMTransmit (I have put some data in a buffer in your workspace)
  585.  
  586.    R0     18 (error message if not acknowledged)
  587.    R1!0   size
  588.      !12  my-ref field of RAMFetch message
  589.      !16  7 ; RAM transmit.
  590.      !20  buffer address             ; copy of value sent in RAM fetch
  591.      !24  number of bytes written to buffer
  592.           (if buffer not full, send another RAMFetch)
  593.  
  594. To write the data into the receiver's buffer, use the following call:
  595.  
  596. Wimp_TransferBlock
  597. Entry:  R0 = task handle of source
  598.         R1 --> source buffer
  599.         R2 = task handle of destination
  600.         R3 --> destination buffer
  601.         R4 = buffer length
  602.         buffer addresses and length are byte-aligned (not nec. word-aligned)
  603.         if the buffer addresses are within application space,
  604.            they are validated to ensure they are within the correct task
  605. Errors: "Invalid task handle"
  606.         "Wimp transfer out of range"
  607.  
  608.  
  609. Application code for direct file transfer
  610. -----------------------------------------
  611.  
  612. NOTE:  In all cases where an unknown message action is received by an
  613.        application, it MUST ignore the message completely.
  614.  
  615. Save file:
  616.         1.      transmit DataSave message
  617.  
  618.         2.      if DataSaveAck returned, save file and send DataLoad
  619.                    Unless receiver is the Filer, the DataSaveAck would refer
  620.                    to "<Wimp$Scrap>", and the estimated size field would be
  621.                    set to -1, indicating that the file is not 'safe'.
  622.  
  623.                    Errors encountered during file saving are reported by the
  624.                    sender, and DataLoad is not sent.
  625.  
  626.         3.      if RAMFetch returned, send RAMTransmit and loop until done
  627.  
  628. NOTE:  all messages in this protocol apart from the DataSave should quote the
  629.        other side's my_ref field in their your_ref fields, to ensure that the
  630.        messages are acknowledged correctly.
  631.  
  632. Receiver:
  633.         1.      DataSave received
  634.  
  635.         2.      If data can be loaded from RAM, send back a RAMFetch
  636.                    (look at approx data size in DataSave message, but do not
  637.                     rely on its absolute accuracy, ie. be prepared for MORE
  638.                     data than that to be sent)
  639.  
  640.                 If RAMFetch not acknowledged, load from a file (step 3)
  641.  
  642.                    if RAMTransmit received,
  643.                       finished if buffer NOT filled,
  644.                       else send another RAMFetch and loop.
  645.                       if any RAMFetch other than the 1st is not acknowledged,
  646.                          report error
  647.                       - no need to check your_ref field if RAMFetch (18) used,
  648.                         since the RAMFetch will not be acknowledged
  649.                       if pipe break received, shut up quietly
  650.  
  651.         3.      If data must be in a file, return DataSaveAck "<Wimp$Scrap>",
  652.                 setting the 'estimated size' field to -1.  If the environment
  653.                 variable Wimp$Scrap does not exist, the error message
  654.                 "<Wimp$Scrap> not defined" should be generated.
  655.  
  656.                 If DataLoad received, load file, delete and return DataLoadAck
  657.                    Note that the your_ref field of the DataLoad tells the
  658.                    receiver whether the file is the scrap file.
  659.  
  660. Minimal functionality is for the sender to only cope with DataSaveAck, and
  661. for the receiver to only cope with file-based i/o.  If the receiver wishes to
  662. engage in RAMFetch operations, it should be prepared for the sender to be
  663. ignorant of that protocol - ie. it should be prepared to revert to the scrap
  664. file mechanism.
  665.  
  666.  
  667. Ramifications
  668. -------------
  669.  
  670. The main change to the spec is that all applications must be prepared to
  671. recognise DataSave, and return at least a DataSaveAck to <Wimp$Scrap>,
  672. followed by acting on DataLoad (which they do anyway), and deleting the file
  673. after loading it, if the your_ref field of the DataLoad refers to their
  674. DataSaveAck message.
  675.  
  676. Another change is that when files are saved onto the Filer, this action is
  677. followed by a DataLoad message being sent.  Therefore the Filer must respond
  678. to the DataLoad message with a DataLoadAck (if the DataLoad your_ref field is
  679. correct).
  680.  
  681. It might have been possible to shift the onus onto the saver of the data, by
  682. sending a DataLoad message to the unsuspecting receiver.  However, this would
  683. entail the creation and deletion of a scrap file whenever the data is dragged
  684. onto the desktop background!
  685.  
  686.